import { formatBytes } from '@/utils/format'

export default function useConfig() {
  const { allRegionOptions } = useRegions()
  const columns = buildColumns([
    {
      title: '所属区域',
      dataIndex: 'region_name',
      minWidth: 180,
      render({ record }) {
        return getOptionLabel(record.region_id, allRegionOptions.value)
      },
    },
    {
      title: 'IP地址',
      dataIndex: 'host_ip',
      format: 'copy',
      minWidth: 180,
    },
    {
      title: 'CPU型号',
      minWidth: 180,
      render({ record }) {
        return `${record.cpu_info.vendor} ${record.cpu_info.arch} ${record.cpu_info.model}`
      },
    },
    {
      title: '内存',
      minWidth: 96,
      render({ record }) {
        return `${formatBytes(record.memory_mb * 1024 ** 2, 'GB').value}G`
      },
    },
    // {
    //   title: '磁盘',
    //   minWidth: 96,
    //   render({ record }) {
    //     // return formatBytes(record.local_gb * 1024 ** 3, 'GB').value
    //     return `${record.local_gb}G`
    //   },
    // },
    {
      title: '标签',
      dataIndex: 'tag',
      width: 220,
      slotName: 'tag',
    },
  ])

  return { columns }
}
